package org.blade.personal.controller.codegen;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.blade.personal.component.Const;
import org.blade.personal.manager.ModelDefinedManager;
import org.blade.personal.manager.codeGen.PdmTableManager;
import org.blade.personal.utils.Pager;
import org.blade.personal.utils.pdm.PdmTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 代码产生器
 * @author ZGF
 *
 */
@Controller
@RequestMapping("/CodeGenerator/*")
public class CodeGeneratorContoller {

	private ModelDefinedManager modelDefinedManager;
	
	@Autowired	
	private PdmTableManager pdmTableManager;
	
	public String generating(@RequestParam Map<String,Object> param){
		
		Long id = MapUtils.getLong(param, "id");
		return null;
	}
	
	@ResponseBody
	@RequestMapping("getTable")
	public Map<String,Object> getTable(@RequestParam Map<String,Object> param){
		
		Long pageSize = MapUtils.getLong(param, Const.Buesiness.PAGE_SIZE);
		Long pageNum = MapUtils.getLong(param, Const.Buesiness.PAGE_NUM); 
		Pager<PdmTable> pager = new Pager<PdmTable>(pageSize,pageNum,0l);
		String id =  MapUtils.getString(param, "pkgId"); 
		
		pdmTableManager.findTable(pager, id);
		
		Map<String,Object> resp = new HashMap<String,Object>();
		resp.put(Const.Buesiness.DATA, pager.getEntities());
		resp.put(Const.Buesiness.TOTAL_COUNT, pager.getTotalCount());
		return resp;
	}
}
